define(['esri/geometry/Point', 'dojo/_base/declare'], function(Point, declare) {
  'use strict';

  return declare(null, {
    startLon: null, //起始经度
    startLat: null, //起始纬度
    endLon: null, //终止经度
    endLat: null, //终止纬度
    lonCount: null, //经度跨度数量
    latCount: null, //纬度跨度数量
    lonStep: null, //经度步长
    latStep: null, //纬度步长
    ds: null, //源数据
    pointsArr: [], //点集合

    constructor: function(json) {
      // console.log(json);
      this.startLon = json.startLon;
      this.startLat = json.startLat;
      this.endLon = json.endLon;
      this.endLat = json.endLat;
      this.lonCount = json.lonCount;
      this.latCount = json.latCount;
      this.lonStep = json.lonStep;
      this.latStep = json.latStep;
      this.ds = json.DS;
      this.calcPoints();
    },

    getPointsArr: function() {
      return this.pointsArr;
    },
    //计算所有点并存入pointsArr
    calcPoints: function() {
      this.pointsArr = [];
      // console.log('ds.length = ' + this.ds.length);
      // console.log(this.ds);
      if (this.ds.length == 0) return;

      //循环纬度
      for (var i = 0; i < this.ds.length; i++) {
        //纬度自增
        var lat = this.startLat + this.latStep * i;

        //循环经度
        for (var j = 0; j < this.ds[i].length; j++) {
          var lon = this.startLon + this.lonStep * j;
          // 排除空数据
          if (this.ds[i][j] != 999999.0) {
            var point = new Point(lon, lat);
            point.value = this.ds[i][j];
            this.pointsArr.push(point);
          }
        }
      }
    }
  });
});
